
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-11-12
 * Time: 19:50
 */
public class soulosion {


    public static int numJewelsInStones(String jewels, String stones) {
        int count=0;
        Map<Character,Integer> map=new HashMap<Character,Integer>();

        for (int i = 0; i < stones.length(); i++) {
          map.put(stones.charAt(i),map.getOrDefault(stones.charAt(i),0)+1);
        }
        for (int i = 0; i < jewels.length(); i++) {
            if(map.containsKey(jewels.charAt(i))){
                count+=map.get(jewels.charAt(i));
            }
        }
      return count;
    }
    // 注意类名必须为 Main, 不要有任何 package xxx 信息

    public static void main(String[] args) {
        System.out.println(numJewelsInStones("aA", "aAAbbb"));
    }
        public static void main1(String[] args) {
            Scanner in = new Scanner(System.in);
            // 注意 hasNext 和 hasNextLine 的区别
            while (in.hasNext()) { // 注意 while 处理多个 case
                String a = in.next();
                String b = in.next();
                a=a.toUpperCase();
                b=b.toUpperCase();
                Set<Character> set=new LinkedHashSet<>();
                Set<Character> set1=new LinkedHashSet<>();


                for (int i = 0; i < a.length(); i++) {
                    set.add(a.charAt(i));
                }
                for (int i = 0; i < b.length(); i++) {
                    set1.add(b.charAt(i));
                }
                char[] arr=new char[set.size()];
                int index=0;
                for(Character n :set){
                    arr[index++]=n;
                }
                for (int i = 0; i < set.size(); i++) {
                    if(!set1.contains(arr[i])){
                        System.out.print(arr[i]);
                    }
                }
            }
    }
}


